package StringExercise;
//boolean matches(String regex):匹配
public class MatchesDemo1 {
    public static void main(String[] args) {
        String email1="zhang@tedu.cn";
        String regex1="[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        boolean match1=email1.matches(regex1);
        if(match1){
            System.out.println("邮箱格式正确");
        }else {
            System.out.println("邮箱格式不正确");
        }


        String email2="wuwu@tedu.com.cn";
        String regex2="[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        boolean match2=email2.matches(regex2);
        if(match2){
            System.out.println("邮箱格式正确");
        }else {
            System.out.println("邮箱格式不正确");
        }

    }

}
